﻿@model IEnumerable<HQPad.Models.Spell>

@{
    ViewBag.Title = "Spells";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
    int rulesId = (int)ViewBag.RuleSetID;
}

<h1>Spells</h1>

@section PageScripts {
    <script src="@Url.Content("~/Scripts/global.js")" type="text/javascript"></script>
}

<section class="content">

    <div class="block">
        <p>@Html.ActionLink("Create new spell", "Create", new { ruleSetId = rulesId }, new { @class="button" })</p>
    </div>

    <div class="block">
        @using (Html.BeginForm("Index", "Spell", "Post"))
        {
            <h3>Filter</h3>
            <ul class="filters">
                <li>Colour: @Html.DropDownList("Colour", "All")</li>
            </ul>

            <script type="text/javascript">
                $(document).ready(function () {
                    $('.goFilter').click(function (event) {
                        // get qs parameters.
                        var value = $('#Colour').val();
                        var newUrl;
                        newUrl = addToUrl(window.location.href, 'colour', value);

                        $(this).attr('href', newUrl);
                    });
                });
            </script>
    
            <p><a href='#' class="goFilter button" >Filter</a></p>
        }

        <table>
            <tr>
                <th>
                    Name
                </th>
                <th>
                    Level
                </th>
                <th>
                    Colour
                </th>
                <th></th>
            </tr>

        @foreach (var item in Model) {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Level)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Colour)
                </td>
                <td>
                    @Html.ActionLink("Edit", "Edit", new { ruleSetId = item.RuleSetID, slug=item.Slug.ToLower() }) |
                    @Html.ActionLink("Delete", "Delete", new { ruleSetId = item.RuleSetID, slug = item.Slug.ToLower() })
                </td>
            </tr>
        }

        </table>

    </div>
</section>